<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<!--suppress MybatisGenerateCustomPluginInspection -->
<generatorConfiguration>
    <context id="MysqlContext" targetRuntime="MyBatis3Simple" defaultModelType="flat">
        <property name="javaFileEncoding" value="UTF-8"/>
        <property name="useMapperCommentGenerator" value="false"/>
        <!-- 由于beginningDelimiter和endingDelimiter的默认值为双引号(")，在Mysql中不能这么写，所以还要将这两个默认值改为`  -->
        <property name="beginningDelimiter" value="`"/>
        <property name="endingDelimiter" value="`"/>

        <!--mapper接口  自定义Mapper接口 模板-->
        <plugin type="com.zxkj.ssm.weixin.shop.mybatis.generator.plugins.TemplateFilePlugin">
            <property name="targetProject" value="${targetProject}/src/main/java"/>
            <property name="targetPackage" value="${mybatisMapper}"/>
            <property name="templatePath" value="template/mapper.html"/>
            <property name="mapperSuffix" value="MapperDao"/>
            <property name="fileName" value="${tableClass}${mapperSuffix}.java"/>
        </plugin>


        <!--mapper.xml-->
        <plugin type="com.zxkj.ssm.weixin.shop.mybatis.generator.plugins.TemplateFilePlugin">
            <property name="targetProject" value="${targetProject_sqlMap}/src/main/java"/>
            <property name="targetPackage" value="${mybatisMapperSqlXml}"/>
            <property name="mapperPackage" value="${mybatisMapper}"/>
            <property name="templatePath" value="template/mapperXml.html"/>
            <property name="mapperSuffix" value="MapperDao"/>
            <property name="fileName" value="${tableClass}${mapperSuffix}.xml"/>
        </plugin>

        <!--测试输出单个文件，每个表都会生成一个对应的文件-->
        <plugin type="com.zxkj.ssm.weixin.shop.mybatis.generator.plugins.TemplateFilePlugin">
            <property name="targetProject" value="${targetProject_sqlMap}/src/main/java"/>
            <property name="targetPackage" value="${mybatisMapperSqlXml}"/>
            <property name="templatePath" value="template/test/test-one.ftl"/>
            <property name="fileName" value="${tableClass}Test.txt"/>
            <!--默认值是下面这个，可以不配置-->
            <property name="templateFormatter"
                      value="com.zxkj.ssm.weixin.shop.mybatis.generator.formatter.FreemarkerTemplateFormatter"/>
        </plugin>
        <!--测试输出整个文件，所有表都可用，一次只生成一个文件，用于聚合所有表使用-->
        <plugin type="com.zxkj.ssm.weixin.shop.mybatis.generator.plugins.TemplateFilePlugin">
            <property name="singleMode" value="false"/>
            <property name="targetProject" value="${targetProject_sqlMap}/src/main/java"/>
            <property name="targetPackage" value="${mybatisMapperSqlXml}"/>
            <property name="templatePath" value="template/test/test-all.ftl"/>
            <property name="fileName" value="All.txt"/>
        </plugin>

        <!-- 为生成的Java模型创建一个toString方法 -->
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>

        <!-- 为生成的Java模型类添加序列化接口，并生成serialVersionUID字段 -->
        <plugin type="com.zxkj.ssm.weixin.shop.mybatis.generator.plugins.SerializablePlugin">
            <property name="suppressJavaInterface" value="false"/>
        </plugin>


        <!-- Java模型生成equals和hashcode方法 -->
        <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"></plugin>

        <!-- 生成的代码去掉注释 -->
        <commentGenerator type="com.zxkj.ssm.weixin.shop.mybatis.generator.plugins.CommentGenerator">
            <property name="suppressAllComments" value="true" />
            <property name="suppressDate" value="true"/>
        </commentGenerator>

        <!-- 数据库连接 -->
        <jdbcConnection driverClass="${jdbcDriver}"
                        connectionURL="${jdbcUrl}"
                        userId="${jdbcUsername}"
                        password="${jdbcPassword}">
        </jdbcConnection>

        <!--MyBatis 生成器只需要生成 Model-->
        <javaModelGenerator targetPackage="${mybatisEntity}" targetProject="${targetProject}/src/main/java">
            <property name="rootClass" value="com.zxkj.ssm.weixin.shop.model.PagerModel"/>
        </javaModelGenerator>

        <!-- MapperXML生成 -->
      <!--  <sqlMapGenerator targetPackage="${mybatisMapperSqlXml}" targetProject="${targetProject_sqlMap}/src/main/java" />-->

        <!-- Mapper接口生成  传统的可以用这个 -->

       <!--
         <javaClientGenerator targetPackage="${mybatisMapper}" targetProject="${targetProject}/src/main/java" type="XMLMAPPER">
            <property name="rootInterface" value="BasicDao"/>
        </javaClientGenerator>
        -->

        <!-- 需要映射的表 -->
        <#list tables as table>
            <table tableName="${table.table_name}" domainObjectName="${table.model_name}"></table>
        </#list>
    </context>
</generatorConfiguration>